home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dspgroup / i2kbd.arc / ARGUS.C next >
Encoding:
C/C++ Source or Header  |  1988-07-03  |  2.6 KB  |  120 lines

  1. #include <stdio.h>
  2. #include <memory.h>
  3. #include <process.h>
  4. #include <graph.h>
  5. #define    CONTROL 0x34
  6. #define    CONT2 0xb4
  7.     int inport,integrate,data[512],datum;
  8.     unsigned prt0,cntrlpt,prt1,prt2;
  9.     int prime,count,i,iter,y[50],baseio,seg320;
  10.     char name[20],buffer[24];
  11.     float summa;
  12. main(argc,argv)
  13. int argc;
  14. char *argv[];
  15.     {
  16.     int k,value,rosso;
  17.     unsigned div;
  18.     long count,bkc;
  19.     float trate,osc,rate;
  20.     baseio=0x300;
  21.     osc = 6.25;
  22.     osc = osc * 1.0e6;
  23.     cntrlpt = baseio + 7;
  24.     prt0 = baseio + 4;
  25.     prt2 = baseio + 6;
  26.     bkc=1;
  27.     rosso=4;
  28.     inp(cntrlpt);   /* halt */
  29.     spawnl(P_WAIT,"intel",argv[0],"gather","d000","300","0",NULL);
  30.     clark:
  31.     cls();
  32.     printf("\n              A R G U S    Project\n");
  33.     printf("          code by Dr.Alberto E. Zagni\n");
  34.     printf("\n ");
  35.     printf("\n Input desired integration in sec. ");
  36.     scanf( "%d",&integrate);
  37.     rate=100;
  38.     integrate=integrate*rate;
  39.     /* count gives you the oscillator "divisor" just as in SIO's */
  40.     count = osc/rate;
  41.     if ( count < 2 ) count += 1;
  42.     trate = osc /(float)count;
  43.     printf("\nRate = %f ",trate);
  44.     /* set timers for desired sampling rate */
  45.     control_timer(count,osc,&trate);
  46.     seg320=0xD000;
  47.     inp(cntrlpt);        /* halt 320 */
  48.     printf("\nHit any character when ready");
  49.     /* routine to check for a keyboard strike and to eat that char */
  50.     ci();
  51.     _setvideomode(_HRES16COLOR);
  52.     _setbkcolor(bkc);
  53.     _setcolor(rosso);
  54.     k=1;
  55.     _moveto(1,179);
  56.     inp(prt2);           /* go 320 */
  57.     while ( !kbhit() ) {              /* read k points */
  58.  
  59.         fulbuf(baseio);         /* read in data from 320 */
  60.         data[k]=datum;
  61.         _lineto(k,180-(data[k]-90)*3);
  62.         _settextposition(1,70);
  63.         printf("%d    ",data[k]);
  64.         k+=1;
  65.         if (k==618) k=1;
  66.     }
  67.  
  68.     inp(cntrlpt);        /* halt 320 */
  69.     _setvideomode(_TEXTC80);
  70.     exit(0);
  71. }                            /* END of program */
  72.  
  73.  
  74. control_timer(cnt,osc,trate)
  75. long cnt;
  76. float *trate,osc;
  77. {
  78.     int ctl,cth;
  79.     /* tell board timer info coming */
  80.     outp(cntrlpt ,CONTROL);
  81.     /* count is timing divisor */
  82.     ctl = cnt & 0xff;    /* lo byte */
  83.     cth = ( cnt >> 8 ) & 0xff;/* hi byte */
  84.     /* control timer 0 */
  85.     outp(prt0 , ctl);
  86.     outp(prt0 , cth);
  87.     /* control timer 2 */
  88.     outp(cntrlpt , CONT2);
  89.     outp(prt2 , ctl);
  90.     outp(prt2 , cth);
  91.     /* compute new sampling rate  for output on screen*/
  92.     *trate = osc/(float)cnt;
  93. }
  94.  
  95. ci()
  96. {
  97.     int kbhit(),getch(),j;
  98.     while (kbhit()==0) {};
  99.       j=getch();
  100. }
  101. cls()
  102. {
  103.     printf("\x1B[2J");
  104. }
  105. fulbuf(baseio)
  106. int baseio;
  107. {
  108.     int i,j,porti;
  109.     j=-1;
  110.     summa=0;
  111.     porti=baseio+4;
  112.     for(i=0;i<integrate;i++) {
  113.         while(inp(baseio+4)==j) {};
  114.         j=inp(porti);
  115.         summa+=abs((inp(baseio+1)<<8)+inp(baseio)-2048);
  116.  
  117.     }
  118.     datum=summa/integrate;
  119. }
  120.